home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-11-06 | 54.9 KB | 1,626 lines |
- Newsgroups: comp.sources.misc
- From: dan%step.uucp@uunet.uu.net (Daniel Weaver)
- Subject: v25i026: ted - Terminfo/termcap test program, Part01/07
- Message-ID: <csm-v25i026=ted.221456@sparky.IMD.Sterling.COM>
- X-Md4-Signature: 850d0c6ae14fe275562f46a2e990709e
- Date: Wed, 6 Nov 1991 04:15:26 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: dan%step.uucp@uunet.uu.net (Daniel Weaver)
- Posting-number: Volume 25, Issue 26
- Archive-name: ted/part01
- Environment: UNIX
-
- Terminfo/termcap test program (TED).
-
- The purpose of this program is to verify the correctness of
- terminfo's/termcaps and to calculate the pads needed for each
- capability. This program is not designed to test curses and
- therefore uses as little of curses as possible. TED was originally
- written to test terminfo's and termcaps were added as an after
- thought. Various places within the program I make the (decidedly
- wrong) assumption that termcaps have a one to one mapping with
- terminfo's. Due to the lack of standardization for termcaps
- I see no other reasonable solution.
-
- See the README for more information.
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # The tool that generated this appeared in the comp.sources.unix newsgroup;
- # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
- # If this archive is complete, you will see the following message at the end:
- # "End of archive 1 (of 7)."
- # Contents: README fun.c
- # Wrapped by dan@step on Fri Nov 1 11:28:23 1991
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'README'\"
- else
- echo shar: Extracting \"'README'\" \(6979 characters\)
- sed "s/^X//" >'README' <<'END_OF_FILE'
- X
- XTerminfo/termcap test program (TED).
- X
- X The purpose of this program is to verify the correctness of
- Xterminfo's/termcaps and to calculate the pads needed for each
- Xcapability. This program is not designed to test curses and
- Xtherefore uses as little of curses as possible. TED was originally
- Xwritten to test terminfo's and termcaps were added as an after
- Xthought. Various places within the program I make the (decidedly
- Xwrong) assumption that termcaps have a one to one mapping with
- Xterminfo's. Due to the lack of standardization for termcaps
- XI see no other reasonable solution.
- X
- XBuilding terminfo's from scratch.
- X I have tried to structure the program in such a way as to
- Xfacilitate the creation of new terminfo's. The tests done at the
- Xbeginning of the program are assumed to be correct later in the code.
- XTED displays the number of lines and columns as part of its initial
- Xoutput. If these values are wrong a large number of tests will
- Xfail or give incorrect results.
- X
- X The following options are designed to help create new terminfo's.
- X
- X -e Echo test. All data typed from the keyboard will be
- X echoed back to the terminal. Control characters are
- X not translated to the up arrow format but are sent
- X as control characters. This allows the user to test an
- X escape sequence and see what it actually does.
- X
- X -S Status report test. This test acts much like the echo test
- X but characters that are sent from the terminal more than
- X one character after a carriage return will be expanded
- X to the up arrow format. For example on a standard ANSI
- X terminal you may type:
- X CR ESC [ c
- X and the response will be echoed as:
- X ^[ [ ? 6 c
- X
- X -g ANSI sgr display. This test assumes you have an ANSI terminal.
- X It displays the sgr number using that sgr to write the text.
- X This helps the programmer know which of the sgr modes are
- X actually implemented by the terminal.
- X Some terminals (such as Tektronix color) use the private
- X use characters to augment the functionality of the sgr command.
- X These private use characters may be interjected into the
- X escape sequence by typing the character ( <, =, >, ? ) after
- X the original display has been shown.
- X
- X -A ANSI status report test. This test queries the terminal in
- X standard ANSI fashion (read VT-100). The results of this test
- X may be useful in helping to determine what options are
- X available.
- X
- XVerifying correctness.
- X
- X After the terminfo has been built TED should be used to verify
- Xthat it is correct. The general philosophy of the program is to
- Xsend something to the terminal and ask the user to check its validity.
- XFor the specific capability tests (using the -p option) the program
- Xwill try to make it easy for the user to see if the cap is doing the
- Xcorrect thing. For example the "Clear to end of line" test will
- Xuse the cap on all but one of the lines, and on the last line, the
- Xprogram will print what the values should be.
- X
- XDetermining pad times.
- X
- X The key to determining pad times is to find out what effective
- Xbaud rate the terminal is running at. The effective baud rate
- Xis the number of characters that the terminal can accept without
- Xhandshaking and without loosing data. This rate is frequently
- Xless than the actual baud rate on the RS-232 line.
- X TED uses the effective baud rate to judge the duration of the
- Xtest and how much a particular escape sequence will perturb the
- Xterminal.
- X The best way to time the terminal is to use some kind of
- Xhandshake such as ENQ/ACK. With this handshake the program
- Xsends an ENQ and waits for an ACK. Many terminals can be setup
- Xto do this (although it is by no means universal). TED will
- Xfunction much better if you can setup your terminal to do ENQ/ACK.
- XThe more common Control S Control Q handshake cannot be used for
- Xthis purpose because it does not tell me if the terminal is idle.
- X Each pad test has a few variables that can help verify the
- Xcorrectness of the pad counts. After a test is completed the
- Xprogram will type "Done." followed by the names of the cap actually
- Xtested. At this point the following characters may be input
- Xto change how the test was run and permit rerunning of the test.
- X d - double the number of lines (or characters) effected.
- X h - half the number of lines (or characters) effected.
- X n - goto the next test
- X p - edit the pad counts
- X r - rerun the test
- X < - make the test shorter
- X > - make the test longer
- X ? - redisplay the Done message
- X <number> - change the number of lines (characters) effected to be
- X this number.
- X <cr> - continue with next test
- X
- X The results of the pad tests will be written to a file. The
- Xfilename will be ted.$TERM (where $TERM is your environment variable).
- XThe data contained within the file should not be taken as gospel.
- XSome of the data (such as for ich1/dch1) is not placed in the file
- Xand can only be obtained by watching the display. System load
- Xwill also effect the results.
- X Not all variables make sense to all tests. For example the number
- Xof lines effected has no effect of clear screen. Once again I must
- Xwarn you about taking this as gospel. Each program has the option
- Xof using "Number of lines effected" or ignoring it. So what works
- Xfor TED and 6 other programs may fail on your favorite spread sheet.
- X
- XThe .termdefs file
- X
- X TED uses the .termdefs file in $HOME to read options for a specific
- Xterminal. The file has the format:
- X terminal-name options ...
- XThe options may be any option that is normally passed on the command line.
- XThe best use for the file is to hold the enquire/acknoledge sequences
- Xneeded for a specific terminal. The default enquire/acknoledge sequence
- Xis conreol E (ENQ) and control F (ACK). This could be represented by
- Xthe command line options -Q 5 -T 6 -j 0. The default sequence works with
- Xa Wyse 50 but not a VT-100. The VT-100 uses <esc> [ c or <esc> Z to
- Xenquire and the response string may be rather long but ends in a c.
- XThe -Q option allows you to set the enquire string to any ASCII characters.
- XThe -Q option is followed by a list of characters entered as decimal
- Xnumbers. For example <esc> [ c becomes -Q 27 91 99 0. The zero
- Xterminates the string. The acknoledge string ends with a c. This
- Xis described by -T 99. The number of characters that have to be thrown
- Xaway is described by -j 6. The throw away characters, which I call
- Xjunk characters, should be large enough to handle the longest response
- Xgiven by the enquire string. It is better to make this number too large
- Xthan too small.
- X The terminal names are scanned with a first fit algorithm. Therefore
- Xlonger names should appear first. If your terminal type is vt100-w and
- Xvt100-w is not in the file, then TED will use vt100 (if it is in the file).
- XIf both vt100-w and vt100 are used in the file then vt100-w should be
- Xfirst.
- X Here is an example of a .termdefs file:
- X
- X wy50 +nx
- X kermit -Q 27 90 0 -T 75 -j 2
- X vt100-w -Q 27 91 99 0 -T 99 -j 6
- X vt100 -Q 27 91 99 0 -T 99 -j 6
- X xtalk -Q 27 91 99 0 -T 99 -j 6
- X
- END_OF_FILE
- if test 6979 -ne `wc -c <'README'`; then
- echo shar: \"'README'\" unpacked with wrong size!
- fi
- # end of 'README'
- fi
- if test -f 'fun.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'fun.c'\"
- else
- echo shar: Extracting \"'fun.c'\" \(44721 characters\)
- sed "s/^X//" >'fun.c' <<'END_OF_FILE'
- X/*
- X** This software is Copyright (c) 1991 by Daniel Weaver.
- X**
- X** Permission is hereby granted to copy, distribute or otherwise
- X** use any part of this package as long as you do not try to make
- X** money from it or pretend that you wrote it. This copyright
- X** notice must be maintained in any copy made.
- X**
- X** Use of this software constitutes acceptance for use in an AS IS
- X** condition. There are NO warranties with regard to this software.
- X** In no event shall the author be liable for any damages whatsoever
- X** arising out of or in connection with the use or performance of this
- X** software. Any use of this software is at the user's own risk.
- X**
- X** If you make modifications to this software that you feel
- X** increases it usefulness for the rest of the community, please
- X** email the changes, enhancements, bug fixes as well as any and
- X** all ideas to me. This software is going to be maintained and
- X** enhanced as deemed necessary by the community.
- X*/
- X/* test the function keys on the terminal */
- X
- X#include "curses.h"
- X#include "ted.h"
- X
- X#define MAX_MODES 256
- X
- Xextern char *malloc();
- X
- X/* scan code externals */
- Xextern int scan_max; /* length of longest scan code */
- Xextern char **scan_up, **scan_down, **scan_name;
- Xextern int *scan_tested, *scan_length;
- X
- X/* local definitions */
- Xstatic char *fk_name[MAX_STRINGS];
- Xstatic char *fkval[MAX_STRINGS];
- Xstatic char *fk_label[MAX_STRINGS]; /* function key labels (if any) */
- Xstatic int fk_tested[MAX_STRINGS];
- Xstatic int fkmax = 1; /* length of longest key */
- Xstatic int got_labels = 0; /* true if we have some labels */
- Xstatic int key_count = 0;
- Xstatic int end_state;
- X
- X/* unknown function keys */
- X#define MAX_FK_UNK 50
- Xstatic char *fk_unknown[MAX_FK_UNK];
- Xstatic int fk_length[MAX_FK_UNK];
- Xstatic int funk;
- X
- Xstatic char default_bank[] = "\033(B\017";
- Xstatic char *puc[] = {"", "<", "=", ">", "?", 0};
- Xstatic int private_use, ape, terminal_class, got_escape;
- Xstatic short ansi_value[256];
- Xstatic char ansi_buf[512], pack_buf[512];
- Xstatic char *ach, *pch;
- X
- Xstruct ansi_reports {
- X int lvl, final;
- X char *text;
- X char *request;
- X};
- X
- Xstatic struct ansi_reports report_list[] = {
- X 0, 'c', "(DA) Primary device attributes", "\033[0c",
- X 1, 0, "(DSR) Terminal status", "\033[5n",
- X 1, 'R', "(DSR) Cursor position", "\033[6n",
- X 62, 0, "(DA) Secondary device attributes", "\033[>0c",
- X 62, 0, "(DSR) Printer status", "\033[?15n",
- X 62, 0, "(DSR) Function key definition", "\033[?25n",
- X 62, 0, "(DSR) Keyboard language", "\033[?26n",
- X 63, 0, "(DECRQSS) Data destination", "\033P$q$}\033\\",
- X 63, 0, "(DECRQSS) Status line type", "\033P$q$~\033\\",
- X 63, 0, "(DECRQSS) Erase attribute", "\033P$q\"q\033\\",
- X 63, 0, "(DECRQSS) Personality", "\033P$q\"p\033\\",
- X 63, 0, "(DECRQSS) Top and bottom margins", "\033P$qr\033\\",
- X 63, 0, "(DECRQSS) Character attributes", "\033P$qm\033\\",
- X 63, 0, "(DECRQSS) Illegal request", "\033P$q@\033\\",
- X 63, 0, "(DECRQUPSS) User pref suplemental set", "\033[&u",
- X 63, 0, "(DECRQPSR) Cursor information", "\033[1$w",
- X 63, 0, "(DECRQPSR) Tab stop information", "\033[2$w",
- X 64, 0, "(DA) Tertiary device attributes", "\033[=0c",
- X 64, 0, "(DSR) Extended cursor position", "\033[?6n",
- X 64, 0, "(DSR) Macro space", "\033[?62n",
- X 64, 0, "(DSR) Memory checksum", "\033[?63n",
- X 64, 0, "(DSR) Data integrity", "\033[?75n",
- X 64, 0, "(DSR) Multiple session status", "\033[?85n",
- X 64, 0, "(DECRQSS) Attribute change extent", "\033P$q*x\033\\",
- X 64, 0, "(DECRQSS) Columns per page", "\033P$q$|\033\\",
- X 64, 0, "(DECRQSS) Lines per page", "\033P$qt\033\\",
- X 64, 0, "(DECRQSS) Lines per screen", "\033P$q*|\033\\",
- X 64, 0, "(DECRQSS) Left and right margins", "\033P$qs\033\\",
- X 64, 0, "(DECRQSS) Local functions", "\033P$q+q\033\\",
- X 64, 0, "(DECRQSS) Local function key control", "\033P$q=}\033\\",
- X 64, 0, "(DECRQSS) Select modifier key reporting", "\033P$q+r\033\\",
- X 64, 0, "(DECRQDE) Window report", "\033[\"v",
- X 0, 0, 0, 0};
- X
- Xstruct request_control {
- X char *text;
- X char *expect;
- X char *request;
- X char *set_mode;
- X char *reset_mode;
- X};
- X
- X/* Request control function selection or setting */
- Xstruct request_control rqss[] = {
- X "Data sent to screen", "0", "$}", "\033[0$}", 0,
- X "Data sent to disabled status line", "0", "$}",
- X "\033[0$~\033[1$}", "\033[0$}",
- X "Data sent to enabled status line", "1", "$}",
- X "\033[2$~\033[1$}", "\033[0$}",
- X "Disbale status line", "0", "$~", "\033[0$~", 0,
- X "Top status line", "1", "$~", "\033[1$~", 0,
- X "Bottom status line", "2", "$~", "\033[2$~", 0,
- X "Eraseable character", "0", "\"q", "\033[0\"q", 0,
- X "Noneraseable character", "1", "\"q", "\033[1\"q", "\033[0\"q",
- X "Top and bottom margins", "3;10", "r", "\0337\033[3;10r",
- X "\033[r\0338",
- X "Top and bottom margins", "default", "r", "\0337\033[r", "\0338",
- X "Character attributes, dim, bold", "1", "m", "\033[2;1m", "\033[m",
- X "Character attributes, bold, dim", "2", "m", "\033[1;2m", "\033[m",
- X "Character attributes, under, rev", "4;7", "m", "\033[4;7m", "\033[m",
- X "Character attributes, color", "35;42", "m", "\033[35;42m", "\033[m",
- X "All character attributes", "", "m", "\033[1;2;3;4;5;6;7;8;9m",
- X "\033[m",
- X 0, 0, 0, 0, 0
- X};
- X
- Xstatic void
- Xkeys_tested(first_time, hex_output)
- Xint first_time, hex_output;
- X { /* display a list of the keys not tested */
- X int i, l;
- X char outbuf[256];
- X
- X put_clear();
- X tty_set();
- X if (tty_can_sync) (void) tty_sync_error();
- X if (got_labels)
- X {
- X putln("Function key labels:");
- X for (i = 0; i < key_count; ++i) {
- X if (fk_label[i])
- X {
- X sprintf(outbuf, "%s %s",
- X fk_name[i] ? fk_name[i] : "??", fk_label[i]);
- X put_columns(outbuf, strlen(outbuf), 16);
- X }
- X }
- X put_newlines(2);
- X }
- X if (funk)
- X {
- X putln("The following keys are not defined:");
- X for (i = 0; i < funk; ++i) {
- X put_columns(fk_unknown[i], fk_length[i], 16);
- X }
- X put_mode(exit_attribute_mode);
- X put_newlines(2);
- X }
- X if (first_time) putln("The following keys are defined:");
- X else putln("The following keys have not been tested:");
- X if (scan_mode)
- X for (i = 0; scan_down[i]; i++) {
- X if (!scan_tested[i])
- X {
- X if (hex_output)
- X strcpy(outbuf, hex_expand_to(scan_down[i], 3));
- X else strcpy(outbuf, expand(scan_down[i]));
- X l = expand_chars;
- X if (hex_output)
- X strcat(outbuf, hex_expand_to(scan_up[i], 3));
- X else strcat(outbuf, expand(scan_up[i]));
- X expand_chars += l;
- X l = strlen(scan_name[i]);
- X if (((char_count + 16) & ~15) +
- X ((expand_chars + 7) & ~7) + l >= columns)
- X put_crlf();
- X else
- X if (char_count) putchp(' ');
- X put_columns(outbuf, expand_chars, 16);
- X put_columns(scan_name[i], l, 8);
- X }
- X }
- X else
- X for (i = 0; i < key_count; i++) {
- X if (!fk_tested[i])
- X {
- X if (hex_output)
- X strcpy(outbuf, hex_expand_to(fkval[i], 3));
- X else strcpy(outbuf, expand(fkval[i]));
- X l = strlen(fk_name[i]);
- X if (((char_count + 16) & ~15) +
- X ((expand_chars + 7) & ~7) + l >= columns)
- X put_crlf();
- X else
- X if (char_count) putchp(' ');
- X put_columns(outbuf, expand_chars, 16);
- X put_columns(fk_name[i], l, 8);
- X }
- X }
- X put_newlines(2);
- X }
- X
- X
- X#ifdef TESTCAP
- Xvoid
- Xenter_lab(key_name, key_value, lab_name, lab_value)
- Xchar *key_name, *key_value, *lab_name, *lab_value;
- X { /* enter a label. Called by getcap() */
- X int j;
- X
- X cap_test(key_name);
- X cap_test(lab_name);
- X /* ignore labels without function key values */
- X if (key_value)
- X {
- X j = strlen(key_value);
- X fkmax = fkmax > j ? fkmax : j;
- X fkval[key_count] = key_value;
- X fk_tested[key_count] = 0;
- X fk_name[key_count] = key_name;
- X fk_label[key_count++] = lab_value;
- X if (lab_value) got_labels = TRUE;
- X }
- X }
- X#endif
- X
- X
- Xvoid
- Xenter_key(name, value)
- Xchar *name, *value;
- X { /* enter a function key. Also called by getcap() */
- X int j;
- X
- X#ifdef TESTCAP
- X cap_test(name);
- X#else
- X can_test(name);
- X#endif
- X if (value)
- X {
- X j = strlen(value);
- X fkmax = fkmax > j ? fkmax : j;
- X /* do not permit duplicates */
- X for (j = 0; j < key_count; j++) {
- X if (!strcmp(fk_name[j], name)) return;
- X }
- X fkval[key_count] = value;
- X fk_tested[key_count] = 0;
- X fk_label[key_count] = NULL;
- X fk_name[key_count++] = name;
- X }
- X }
- X
- X
- Xstatic void
- Xfind_keys()
- X { /* find out which function keys are defined */
- X#ifndef TESTCAP
- X char **string_base;
- X char *fkey_number[MAX_STRINGS]; /* function key number */
- X char *fkey_label[MAX_STRINGS]; /* function key labels */
- X int i, j, k;
- X
- X string_base = &back_tab;
- X for (i = j = 0; strnames[i]; i++) {
- X if (*string_base)
- X if (strncmp(strnames[i], "lf", 2) == 0)
- X {
- X fkey_number[j] = strnames[i];
- X fkey_label[j++] = *string_base;
- X }
- X else
- X if (strnames[i][0] == 'k')
- X enter_key(strnames[i], *string_base);
- X if (string_base == &prtr_non)
- X#ifdef SVR3
- X string_base = &char_padding;
- X#else
- X break;
- X#endif
- X else string_base++;
- X }
- X /* match the labels to the function keys */
- X for (i = 0; i < j; i++) {
- X for (k = 0; k < key_count; k++)
- X if (!strcmp(&fkey_number[i][1], &fk_name[k][1])) {
- X fk_label[k] = fkey_label[i];
- X got_labels = TRUE;
- X break;
- X }
- X }
- X#endif
- X }
- X
- X
- Xstatic void
- Xfresh_line()
- X { /* clear the line for a new fumction key line */
- X if (over_strike) put_crlf();
- X else
- X {
- X put_cr();
- X if (clr_eol) putp(clr_eol);
- X else put_str(" \r");
- X }
- X }
- X
- X
- Xstatic int
- Xend_funky(ch)
- X { /* return true if this is the end */
- X switch (ch) {
- X case 'e':
- X case 'E':
- X end_state = 'e';
- X break;
- X case 'n':
- X case 'N':
- X if (end_state == 'e') end_state = 'n';
- X else end_state = 0;
- X break;
- X case 'd':
- X case 'D':
- X if (end_state == 'n') end_state = 'd';
- X else end_state = 0;
- X break;
- X case 'l':
- X case 'L':
- X if (end_state == 'l') end_state = '?';
- X else end_state = 'l';
- X break;
- X default:
- X end_state = 0;
- X break;
- X }
- X return end_state == 'd';
- X }
- X
- X
- Xstatic int
- Xfound_match(s, hx, cc)
- Xchar *s;
- Xint hx, cc;
- X { /* return true if this string is a match */
- X int j, f;
- X char outbuf[256];
- X
- X if (!*s) return 0;
- X if (scan_mode)
- X for (j = f = 0; scan_down[j]; j++) {
- X if (scan_length[j] == 0) continue;
- X if (!strncmp(s, scan_down[j], scan_length[j]))
- X {
- X if (!f)
- X { /* first match */
- X put_cr();
- X if (hx) put_str(hex_expand_to(s, 10));
- X else put_str(expand_to(s, 10));
- X f = 1;
- X }
- X (void) end_funky(scan_name[j][0]);
- X put_str(" ");
- X put_str(scan_name[j]);
- X scan_tested[j] = 1;
- X s += scan_length[j];
- X if (strncmp(s, scan_up[j], scan_length[j]))
- X {
- X put_str(" scan down");
- X }
- X else s += scan_length[j];
- X if (!*s) break;
- X j = -1;
- X }
- X if (!strncmp(s, scan_up[j], scan_length[j]))
- X {
- X if (!f)
- X { /* first match */
- X put_cr();
- X if (hx) put_str(hex_expand_to(s, 10));
- X else put_str(expand_to(s, 10));
- X f = 1;
- X }
- X put_str(" ");
- X put_str(scan_name[j]);
- X put_str(" scan up");
- X s += scan_length[j];
- X if (!*s) break;
- X j = -1;
- X }
- X }
- X else
- X for (j = f = 0; j < key_count; j++) {
- X if (!strcmp(s, fkval[j]))
- X {
- X if (!f)
- X { /* first match */
- X put_cr();
- X if (hx) put_str(hex_expand_to(s, 10));
- X else put_str(expand_to(s, 10));
- X f = 1;
- X }
- X sprintf(outbuf, " (%s)", fk_name[j]);
- X put_str(outbuf);
- X if (fk_label[j])
- X {
- X sprintf(outbuf, " <%s>", fk_label[j]);
- X put_str(outbuf);
- X }
- X fk_tested[j] = 1;
- X }
- X }
- X if (end_state == '?')
- X {
- X keys_tested(0, hx);
- X tty_raw(cc, char_mask);
- X end_state = 0;
- X }
- X return f;
- X }
- X
- X
- Xstatic int
- Xfound_exit(keybuf, hx, cc)
- Xchar *keybuf;
- Xint hx, cc;
- X { /* return true if the user wants to exit */
- X int j, k;
- X char *s;
- X
- X
- X if (scan_mode)
- X {
- X if (*keybuf == '\0') return TRUE;
- X }
- X else
- X {
- X /* break is a special case */
- X if (*keybuf == '\0')
- X {
- X fresh_line();
- X tty_set();
- X ptext("Hit X to exit");
- X if (wait_here() == 'X') return TRUE;
- X keys_tested(0, hx);
- X tty_raw(cc, char_mask);
- X return FALSE;
- X }
- X /* is this the end? */
- X for (k = 0; j = (keybuf[k] & STRIP_PARITY); k++) {
- X if (end_funky(j)) return TRUE;
- X }
- X
- X j = TRUE; /* does he need an updated list? */
- X for (k = 0; keybuf[k]; k++)
- X j &= (keybuf[k] & STRIP_PARITY) == '?';
- X if (j || end_state == '?')
- X {
- X keys_tested(0, hx);
- X tty_raw(cc, char_mask);
- X end_state = 0;
- X return FALSE;
- X }
- X }
- X
- X put_cr();
- X if (hx) s = hex_expand_to(keybuf, 10);
- X else s = expand_to(keybuf, 10);
- X sprintf(temp, "%s Unknown", s);
- X put_str(temp);
- X for (j = 0; j < MAX_FK_UNK; j++) {
- X if (j == funk)
- X {
- X fk_length[funk] = expand_chars;
- X if (fk_unknown[funk] = malloc(strlen(s) + 1))
- X strcpy(fk_unknown[funk++], s);
- X break;
- X }
- X if (fk_length[j] == expand_chars)
- X if (!strcmp(fk_unknown[j], s)) break;
- X }
- X return FALSE;
- X }
- X
- X
- Xtest_funky(hex_output)
- Xint hex_output;
- X {
- X int i, j, k, len, fk;
- X char outbuf[256];
- X char keybuf[256];
- X
- X find_keys();
- X if (stop_testing)
- X {
- X can_test("(km)(smm)(rmm)");
- X#ifdef SVR3
- X can_test("(nlab)(lw)(lh)(smln)(plm)(rmln)");
- X#endif
- X#ifndef TESTCAP
- X can_test("(pfx)(pfloc)");
- X#endif
- X return;
- X }
- X if (tty_can_sync == 1) verify_time();
- X if (keypad_xmit) putp(keypad_xmit);
- X keys_tested(1, hex_output); /* also clears screen */
- X ptextln("Hit any function key. Type 'end' to quit. Type ? to update the display.");
- X put_crlf();
- X keybuf[0] = '\0';
- X end_state = 0;
- X if (scan_mode) fkmax = scan_max;
- X#ifdef WAIT_MODE
- X sprintf(temp, "All function keys are assumed to be %d characters long. You must pad shorter keys with blanks.", fkmax);
- X ptextln(temp);
- X /* use this code if your OS can not tell if a character is ready.
- X Reads will be done in wait mode. Use blanks to pad short
- X strings. */
- X tty_raw(1, char_mask);
- X while(end_state != 'd') {
- X fflush(stdout);
- X if (!read(fileno(stdin), keybuf, 1)) break;
- X keybuf[0] &= char_mask;
- X fresh_line();
- X for (len = 1; len < fkmax; len++) {
- X keybuf[len] = '\0';
- X if (hex_output)
- X put_str(hex_expand_to(&keybuf[len - 1], 3));
- X else put_str(expand(&keybuf[len - 1]));
- X fflush(stdout);
- X if (!read(fileno(stdin), &keybuf[len], 1)) break;
- X keybuf[len] &= char_mask;
- X }
- X /* come here when typing stops */
- X keybuf[len] = '\0';
- X if (found_match(keybuf, hex_output, 1)) continue;
- X /* backup over the blanks */
- X for ( ; len; keybuf[--len] = '\0')
- X if (keybuf[len - 1] != ' ') break;
- X if (len == 0) continue;
- X if (found_match(keybuf, hex_output, 1)) continue;
- X if (found_exit(keybuf, hex_output, 1)) break;
- X }
- X#else
- X /* use this code if your OS can tell if a character is ready.
- X Reads will be done by read_key() defined in sysdep.c */
- X tty_raw(0, char_mask);
- X while(end_state != 'd') {
- X read_key(keybuf, fkmax);
- X fresh_line();
- X if (found_match(keybuf, hex_output, 0)) continue;
- X if (found_exit(keybuf, hex_output, 0)) break;
- X }
- X#endif
- X if (keypad_local) putp(keypad_local);
- X keys_tested(0, hex_output);
- X if (has_meta_key)
- X {
- X if (char_mask != ALLOW_PARITY)
- X {
- X if (tty_meta_prep()) (void) wait_here();
- X }
- X ptext("Begin meta key test. (km) (smm) (rmm) Hit any key");
- X ptext(" with the meta key. The character will be");
- X ptext(" displayed in hex. If the meta key is working");
- X ptext(" then the most significant bit will be set. Type");
- X ptextln(" 'end' to exit.");
- X tty_raw(1, ALLOW_PARITY);
- X putp(meta_on);
- X
- X for (i = j = k = len = 0; i != 'e' | j != 'n' | k != 'd'; ) {
- X i = j; j = k;
- X k = getchp(ALLOW_PARITY);
- X if (k == EOF) break;
- X if ((len += 3) >= columns)
- X {
- X put_crlf(); len = 3;
- X }
- X sprintf(outbuf, "%02X ", k);
- X put_str(outbuf);
- X k &= STRIP_PARITY;
- X }
- X putp(meta_off);
- X put_crlf();
- X }
- X else
- X {
- X ptextln("This terminal has no meta key. (km)");
- X (void) wait_here();
- X }
- X tty_set();
- X
- X#ifdef SVR3
- X new_test(8);
- X sprintf(temp, "Your terminal has %d labels (nlab) that are %d characters wide (lw) and %d lines high (lh)",
- X num_labels, label_width, label_height);
- X ptext(temp);
- X ptextln(" Testing (smln) (pln) (rmln)");
- X if (label_on) putp(label_on);
- X if (label_width <= 0) label_width = sizeof(outbuf) - 1;
- X for (i = 1; i <= num_labels; i++) {
- X sprintf(outbuf, "L%d..............................", i);
- X outbuf[label_width] = '\0';
- X putp(tparm(plab_norm, i, outbuf));
- X }
- X (void) wait_here();
- X if (label_off) putp(label_off);
- X#endif
- X
- X#ifndef TESTCAP
- X new_test(8);
- X fk = 1; /* use function key 1 for now */
- X if (pkey_xmit)
- X {
- X char mm[256];
- X
- X /* test program function key */
- X sprintf(temp,
- X "(pfx) Set function key %d to transmit abc\\n", fk);
- X ptextln(temp);
- X putp(tparm(pkey_xmit, fk, "abc\n"));
- X sprintf(temp, "Hit function key %d\n", fk);
- X ptextln(temp);
- X for (i = 0; i < 4; ++i) mm[i] = getchp(STRIP_PARITY);
- X mm[i] = '\0';
- X put_crlf();
- X if (mm[0] != 'a' | mm[1] != 'b' | mm[2] != 'c')
- X {
- X sprintf(temp, "Error string recieved was: %s", expand(mm));
- X ptextln(temp);
- X }
- X else putln("Thank you\n");
- X /* if the terminal sent too much, flush it */
- X if (tty_can_sync) (void) tty_sync_error();
- X }
- X else ptextln("Function key transmit (pfx), not present.");
- X
- X if (pkey_local)
- X {
- X /* test local function key */
- X sprintf(temp,
- X "(pfloc) Set function key %d to execute a clear and print \"Done!\"", fk);
- X ptextln(temp);
- X sprintf(temp, "%sDone!", liberated(clear_screen));
- X putp(tparm(pkey_local, fk, temp));
- X sprintf(temp, "Hit function key %d. Then hit return.", fk);
- X ptextln(temp);
- X }
- X else ptextln("Function key execute local (pfloc), not present.");
- X
- X (void) wait_here();
- X /* if the terminal sent anything else, flush it */
- X if (tty_can_sync) (void) tty_sync_error();
- X if (key_f1 && pkey_xmit) putp(tparm(pkey_xmit, fk, key_f1));
- X#endif
- X }
- X
- X
- Xtest_printer()
- X { /* test the printer commands */
- X
- X if (stop_testing)
- X {
- X can_test("(mc4)(mc5)(mc0)(mc5i)");
- X return;
- X }
- X put_clear();
- X putln("Begin printer test.");
- X if (!prtr_on || !prtr_off)
- X {
- X ptextln("Printer on/off missing. (mc5) (mc4)");
- X }
- X else
- X#if defined(SVR3) || defined(XENIX)
- X if (prtr_silent)
- X {
- X ptextln("Your printer is silent. (mc5i) is set.");
- X putp(prtr_on);
- X ptextln("This line should be on the printer but not your screen. (mc5)");
- X putp(prtr_off);
- X ptextln("This line should be only on the screen. (mc4)");
- X }
- X else
- X {
- X ptextln("Your printer is not silent. (mc5i) is reset.");
- X putp(prtr_on);
- X ptextln("This line should be on the printer and the screen. (mc5)");
- X putp(prtr_off);
- X ptextln("This line should only be on the screen. (mc4)");
- X }
- X#else
- X {
- X putp(prtr_on);
- X ptextln("This line should be on the printer. (mc5)");
- X putp(prtr_off);
- X ptextln("This line should only be on the screen. (mc4)");
- X }
- X#endif
- X (void) wait_here();
- X if (print_screen)
- X {
- X ptext("I am going to send the contents of the screen to");
- X ptext(" the printer, then wait for a keystroke from you.");
- X ptext(" All of the text that appears on the screen");
- X ptextln(" should be printed. (mc0)");
- X putp(print_screen);
- X (void) wait_here();
- X }
- X putln("End of printer test.");
- X }
- X
- X
- Xstatic void
- Xline_pattern()
- X { /* put up a pattern that will help count the number of lines */
- X int i, j;
- X
- X put_clear();
- X if (over_strike)
- X for (i = 0; i < 100; i++) {
- X if (i) put_crlf();
- X for (j = i / 10; j; j--) put_this(' ');
- X put_this('0' + ((i + 1) % 10));
- X }
- X else /* I assume it will scroll */
- X for (i = 100; i; i--) {
- X sprintf(temp, "\r\n%d", i);
- X put_str(temp);
- X }
- X }
- X
- X
- Xstatic void
- Xcolumn_pattern()
- X { /* put up at pattern that will help count the number of columns */
- X int i, j;
- X
- X put_clear();
- X for (i = 0; i < 20; i++) {
- X for (j = 1; j < 10; j++) {
- X put_this('0' + j);
- X }
- X put_this('.');
- X }
- X }
- X
- X
- Xtest_report(crx, hex_display)
- Xint crx, hex_display;
- X { /* status report and echo test */
- X int i, j, ch, crp, high_bit, save_scan_mode;
- X char buf[1024];
- X char txt[8];
- X
- X put_clear();
- X if (crx == 1)
- X {
- X ptext("Characters after a CR or LF will be echoed as");
- X ptext(" is. All other characters will be expanded. Type");
- X ptext(" 'end' to exit. Type");
- X ptext(" 'echo' to redisplay last report. Type");
- X ptext(" 'hex' to redisplay last report in hex. Type");
- X ptextln(" 'clear' to clear screen.");
- X }
- X else /* echo test */
- X {
- X ptext("Begin echo test. Type");
- X ptext(" 'end' to exit. Type");
- X ptext(" 'hex' to display characters in hex. Type");
- X ptext(" 'high' to toggle high order bit on output. Type");
- X ptextln(" 'clear' to clear screen.");
- X }
- X txt[sizeof(txt) - 1] = '\0';
- X save_scan_mode = scan_mode;
- X tty_raw(1, char_mask);
- X for (i = crp = high_bit = 0; ; ) {
- X ch = getchp(char_mask);
- X if (ch == EOF) break;
- X if (i >= sizeof(buf) - 1) i = 0;
- X buf[i++] = ch;
- X buf[i] = '\0';
- X for (j = 0; j < sizeof(txt) - 1; j++) {
- X txt[j] = txt[j + 1];
- X }
- X txt[sizeof(txt) - 1] = ch & STRIP_PARITY;
- X if (crx == 0) /* echo test */
- X {
- X if (hex_display) ptext(hex_expand_to(&buf[i - 1], 3));
- X else putch(ch | high_bit);
- X }
- X else /* status report test */
- X if (ch == '\n' | ch == '\r')
- X {
- X put_crlf();
- X crp = 0;
- X }
- X else
- X if (crp++ < crx) putch(ch | high_bit);
- X else put_str(expand(&buf[i - 1]));
- X if (!strncmp(&txt[sizeof(txt) - 7], "columns", 7))
- X {
- X column_pattern();
- X buf[i = 0] = '\0';
- X crp = 0;
- X }
- X if (!strncmp(&txt[sizeof(txt) - 5], "lines", 5))
- X {
- X line_pattern();
- X buf[i = 0] = '\0';
- X crp = 0;
- X }
- X if (!strncmp(&txt[sizeof(txt) - 5], "clear", 5))
- X {
- X put_clear();
- X buf[i = 0] = '\0';
- X crp = 0;
- X }
- X if (!strncmp(&txt[sizeof(txt) - 4], "high", 4))
- X {
- X high_bit ^= 0x80;
- X if (high_bit) ptextln("\nParity bit set");
- X else ptextln("\nParity bit reset");
- X }
- X if (!strncmp(&txt[sizeof(txt) - 4], "echo", 4))
- X {
- X /* display the last status report */
- X /* clear bypass condition on Tek terminals */
- X put_crlf();
- X buf[i -= 4] = '\0';
- X put_str(expand(buf));
- X }
- X if (save_scan_mode &&
- X !strncmp(&txt[sizeof(txt) - 4], "scan", 4))
- X {
- X /* toggle scan mode */
- X scan_mode = !scan_mode;
- X }
- X if (!strncmp(&txt[sizeof(txt) - 3], "end", 3)) break;
- X if (!strncmp(&txt[sizeof(txt) - 3], "hex", 3))
- X if (crx)
- X {
- X /* display the last status report */
- X /* clear bypass condition on Tek terminals */
- X put_crlf();
- X buf[i -= 3] = '\0';
- X put_str(hex_expand_to(buf, 3));
- X }
- X else hex_display = !hex_display;
- X if (!strncmp(&txt[sizeof(txt) - 3], "two", 3)) crx = 2;
- X if (!strncmp(&txt[sizeof(txt) - 3], "one", 3)) crx = 1;
- X if (!strncmp(&txt[sizeof(txt) - 3], "all", 3)) crx = 0;
- X }
- X scan_mode = save_scan_mode;
- X put_crlf();
- X tty_set();
- X if (crx) ptextln("End of status report test.");
- X else ptextln("End of echo test.");
- X }
- X
- X
- Xstatic int
- Xpack_ansi()
- X { /* read and pack an ANSI character */
- X int ch;
- X
- X if (*pch) return *pch++;
- X
- X while (1) {
- X ch = getchp(char_mask);
- X if (ch == EOF) return EOF;
- X if (ch == A_DC1 || ch == A_DC3) continue;
- X *ach++ = ch; *ach = '\0';
- X if (got_escape && ch >= ' ')
- X {
- X got_escape = 0;
- X if (ch < '@' || ch > '_')
- X {
- X *pch++ = A_ESC;
- X *pch = ch;
- X pch[1] = '\0';
- X return A_ESC;
- X }
- X ch += 0x40;
- X break;
- X }
- X else
- X if (ch == A_ESC) got_escape = 1;
- X else break;
- X }
- X *pch++ = ch; *pch = '\0';
- X return ch;
- X }
- X
- X
- Xstatic void
- Xread_ansi()
- X { /* read an ANSI status report */
- X int ch;
- X
- X fflush(stdout);
- X ach = ansi_buf; pch = pack_buf;
- X ansi_buf[0] = pack_buf[0] = '\0';
- X got_escape = 0;
- X ch = pack_ansi();
- X if (ch == A_ESC)
- X do {
- X ch = pack_ansi();
- X if (ch == EOF) return;
- X } while (ch < '0' || ch > '~');
- X else
- X if (ch == A_CSI)
- X do {
- X ch = pack_ansi();
- X if (ch == EOF) return;
- X } while (ch < '@' || ch > '~');
- X else
- X if (ch == A_DCS)
- X do {
- X ch = pack_ansi();
- X if (ch == EOF) return;
- X } while (ch != A_ST);
- X return;
- X }
- X
- X
- Xstatic int
- Xvalid_mode(expected)
- Xint expected;
- X { /* read a terminal mode status report and parse the result */
- X char *s;
- X int ch, terminator;
- X
- X read_ansi();
- X
- X ape = 0;
- X ch = pack_buf[0] & 0xff;
- X if (ch != A_CSI && ch != A_DCS) return FALSE;
- X
- X s = pack_buf + 1;
- X private_use = 0;
- X if (*s >= '<' & *s <= '?') private_use = *s++;
- X ansi_value[0] = 0;
- X terminator = 0;
- X for ( ; ch = *s; s++) {
- X if (ch >= '0' && ch <= '9')
- X ansi_value[ape] = ansi_value[ape] * 10 + ch - '0';
- X else
- X if (ch == ';' || ch == ':')
- X ansi_value[++ape] = 0;
- X else
- X if (ch >= '<' && ch <= '?')
- X private_use = ch;
- X else
- X if (ch >= ' ')
- X terminator = (terminator << 8) | ch;
- X else break;
- X }
- X return terminator == expected;
- X }
- X
- X
- Xstatic int
- Xread_reports()
- X { /* read all the reports in the ANSI report structure */
- X int i, j, k, tc, vcr, lc;
- X char *s;
- X
- X lc = 5;
- X terminal_class = tc = 0;
- X for (i = 0; report_list[i].text; i++, lc++) {
- X if (terminal_class < report_list[i].lvl &&
- X tc < report_list[i].lvl)
- X {
- X j = wait_here();
- X if (j != 'c' && j != 'C') return j;
- X tc = report_list[i].lvl;
- X }
- X else
- X if (lc >= lines)
- X {
- X (void) wait_here();
- X lc = 1;
- X }
- X sprintf(temp, "%s (%s) ", report_list[i].text,
- X expand_command(report_list[i].request));
- X ptext(temp);
- X for (j = strlen(temp); j < 49; j++) putchp(' ');
- X putp(report_list[i].request);
- X vcr = 0;
- X if (report_list[i].final == 0) read_ansi();
- X else
- X if (valid_mode(report_list[i].final))
- X switch(report_list[i].final) {
- X case 'c':
- X terminal_class = ansi_value[0];
- X break;
- X case 'R':
- X vcr = TRUE;
- X break;
- X }
- X j = pack_buf[0] & 0xff;
- X if (j == A_CSI || j == A_DCS)
- X {
- X s = expand(ansi_buf);
- X if (char_count + expand_chars >= columns)
- X {
- X put_str("\r\n ");
- X lc++;
- X }
- X put_str(s);
- X }
- X put_crlf();
- X if (vcr)
- X { /* find out how big the screen is */
- X putp(report_list[i].request);
- X if (!valid_mode('R')) continue;
- X j = ansi_value[0];
- X k = ansi_value[1];
- X putp("\033[255B\033[255C\033[6n");
- X if (!valid_mode('R')) continue;
- X sprintf(temp, "\033[%d;%dH", j, k);
- X putp(temp);
- X ptext("(DSR) Screen size (CSI 6 n)");
- X for (j = char_count; j < 50; j++) putchp(' ');
- X sprintf(temp, "%d x %d", ansi_value[1], ansi_value[0]);
- X ptextln(temp);
- X
- X }
- X }
- X return wait_here();
- X }
- X
- X
- Xstatic int
- Xrequest_cfss()
- X { /* Request Control function selection or settings */
- X int i, j, k, l, ch;
- X char *s;
- X
- X put_clear();
- X ptextln("Request Expected Received");
- X put_crlf();
- X for (i = 0; rqss[i].text; i++) {
- X ptext(rqss[i].text);
- X j = strlen(rqss[i].text) + strlen(rqss[i].expect);
- X putchp(' ');
- X for (j++; j < 40; j++) putchp(' ');
- X ptext(rqss[i].expect);
- X putchp(' ');
- X putp(rqss[i].set_mode);
- X sprintf(temp, "\033P$q%s\033\\", rqss[i].request);
- X putp(temp);
- X read_ansi();
- X putp(rqss[i].reset_mode);
- X putchp(' ');
- X for (j = 0; ansi_buf[j]; j++) {
- X if (ansi_buf[j] == 'r')
- X {
- X for (k = j++; ch = (ansi_buf[k] & 0xff); k++)
- X if (ch == A_ESC) break;
- X else
- X if (ch == A_ST) break;
- X ansi_buf[k] = '\0';
- X s = expand(&ansi_buf[j]);
- X if (char_count + expand_chars >= columns)
- X put_str("\r\n ");
- X put_str(s);
- X }
- X }
- X put_crlf();
- X }
- X /* calculate the valid attributes */
- X ptext("Valid attributes: 0");
- X j = 0;
- X for (i = 1; i < 20; i++) {
- X sprintf(temp, "\033[0;%dm\033P$qm\033\\", i);
- X putp(temp);
- X (void) valid_mode('m');
- X if (ape > 0)
- X {
- X j = i;
- X sprintf(temp, "\033[0m; %d", i);
- X putp(temp);
- X }
- X }
- X put_crlf();
- X /* calculate how many parameters can be sent */
- X ptext("Max number of parameters: ");
- X sprintf(temp, "%dm\033P$qm\033\\", j);
- X l = -1;
- X if (j > 0)
- X for (l = 1; l < 33; l++ ) {
- X putp("\033[0");
- X for (ch = 1; ch <= l; ch++) put_this(';');
- X putp(temp);
- X (void) valid_mode('m');
- X if (ape == 0) break;
- X }
- X putp("\033[m");
- X if (l >= 0)
- X {
- X sprintf(temp, "%d", l);
- X ptext(temp);
- X }
- X else ptext("unknown");
- X put_crlf();
- X return wait_here();
- X }
- X
- X
- Xstatic
- Xmode_display(p, n, c, s, r)
- Xchar *p;
- Xchar n, c, s, r;
- X { /* print the mode display entry */
- X int k;
- X
- X sprintf(temp, "%s%d (%c, %c, %c)", p, n, c, s, r);
- X k = strlen(temp);
- X if (char_count + k >= columns) put_crlf();
- X for ( ; k < 14; k++) putchp(' ');
- X put_str(temp);
- X }
- X
- X
- Xstatic void
- Xterminal_state()
- X { /* test DECRQM status reports */
- X int i, j, k, l, modes_found;
- X char *s;
- X char buf[256], tms[256];
- X char mode_puc[MAX_MODES], mode_number[MAX_MODES];
- X char set_value[MAX_MODES], reset_value[MAX_MODES];
- X char current_value[MAX_MODES];
- X
- X ptext("Testing terminal mode status. (CSI 0 $ p)");
- X putp("\033[0$p");
- X modes_found = 0;
- X tms[0] = '\0';
- X if (valid_mode(('$' << 8) | 'y'))
- X for (i = 0; puc[i]; i++) {
- X put_crlf();
- X if (i)
- X {
- X sprintf(temp, "Private use: %c", puc[i][0]);
- X }
- X else strcpy(temp, "Standard modes:");
- X k = strlen(temp);
- X ptext(temp);
- X for (j = 0; j < sizeof(buf); buf[j++] = ' ');
- X for (j = l = 0; j < 255 && j - l < 50; j++) {
- X sprintf(temp, "\033[%s%d$p", puc[i], j);
- X putp(temp);
- X if (!valid_mode(('$' << 8) | 'y'))
- X { /* not valid, save terminating value */
- X s = expand(ansi_buf);
- X sprintf(tms, "%s%s%d %s ", tms, puc[i], j, s);
- X break;
- X }
- X if (private_use != puc[i][0]) break;
- X if (ansi_value[0] != j) break;
- X if (ansi_value[1])
- X {
- X l = j;
- X if (k > 70)
- X {
- X buf[k] = '\0';
- X put_crlf();
- X ptextln(buf);
- X for (k = 0; k < sizeof(buf); )
- X buf[k++] = ' ';
- X k = 0;
- X }
- X sprintf(temp, " %d", j);
- X ptext(temp);
- X k += strlen(temp);
- X buf[k - 1] = ansi_value[1] + '0';
- X if (modes_found >= MAX_MODES) continue;
- X current_value[modes_found] =
- X ansi_value[1] + '0';
- X /* some modes never return */
- X if ((i == 0 && j == 13) /* control execution */
- X || (puc[i][0] == '?' && j == 2)) /* VT52 */
- X set_value[modes_found] =
- X reset_value[modes_found] = '-';
- X else set_value[modes_found] =
- X reset_value[modes_found] = ' ';
- X mode_puc[modes_found] = i;
- X mode_number[modes_found++] = j;
- X }
- X }
- X buf[k] = '\0';
- X if (buf[k - 1] != ' ')
- X {
- X put_crlf();
- X ptext(buf);
- X }
- X }
- X
- X if (i = modes_found)
- X {
- X put_crlf();
- X put_crlf();
- X if (tms[0]) ptextln(tms);
- X ptext("Hit 'Y' to test mode set/reset states.");
- X i = wait_here();
- X }
- X if (i == 'y' || i == 'Y')
- X while (1) {
- X#ifdef STATUSFIX
- X FILE *fp;
- X
- X#ifdef TEDANSI
- X fp = fopen("ted.ansi", "w");
- X#else
- X fp = fopen("/dev/console", "w");
- X#endif
- X#endif
- X for (i = j = 0; j < modes_found; j = ++i >> 1) {
- X if (set_value[j] == '-') continue;
- X k = (current_value[j] ^ i) & 1;
- X sprintf(temp, "\033[%s%d%c\033[%s%d$p",
- X puc[mode_puc[j]], mode_number[j],
- X k ? 'l' : 'h',
- X puc[mode_puc[j]], mode_number[j]);
- X#ifdef STATUSFIX
- X if (fp)
- X {
- X fprintf(fp, "%s\n", expand(temp));
- X fflush(fp);
- X }
- X#endif
- X putp(temp);
- X if (!valid_mode(('$' << 8) | 'y')) continue;
- X if (k) reset_value[j] = ansi_value[1] + '0';
- X else set_value[j] = ansi_value[1] + '0';
- X }
- X put_str("\033[30l"); /* added for GORT bug (WY-185) */
- X#ifdef STATUSFIX
- X if (fp) fclose(fp);
- X#endif
- X tty_set();
- X /* print the results */
- X put_clear();
- X putln("mode (initial, set, reset)");
- X for (j = 0; j < modes_found; j++) {
- X mode_display(puc[mode_puc[j]], mode_number[j],
- X current_value[j], set_value[j], reset_value[j]);
- X }
- X ptext("\n\nHit 'R' to repeat test. 'S' to sort results.");
- X i = wait_here();
- X if (i == 's' || i == 'S')
- X { /* print the same stuff, sorted by current_value */
- X put_crlf();
- X for (i = '1'; i <= '4'; i++) {
- X for (j = 0; j < modes_found; j++) {
- X if (current_value[j] == i)
- X mode_display(puc[mode_puc[j]],
- X mode_number[j], current_value[j],
- X set_value[j], reset_value[j]);
- X }
- X }
- X ptext("\n\nHit 'R' to repeat test.");
- X i = wait_here();
- X }
- X if (i != 'r' && i != 'R') break;
- X tty_raw(1, char_mask);
- X }
- X else tty_set();
- X }
- X
- X
- Xtest_ansi_reports()
- X { /* test ansi status reports */
- X int i;
- X
- X put_clear();
- X ptext("Begin ANSI status report testing. ");
- X ptext(" Parity bit set will be displayed in reverse video. ");
- X ptextln(" If the terminal hangs, hit any alphabetic key.");
- X put_crlf();
- X tty_raw(1, char_mask);
- X
- X do {
- X i = read_reports();
- X } while(i == 'r' || i == 'R');
- X
- X if (terminal_class >= 63)
- X {
- X do {
- X i = request_cfss();
- X } while(i == 'r' || i == 'R');
- X terminal_state();
- X }
- X else tty_set();
- X
- X putln("\nEnd of ANSI status report test.");
- X (void) wait_here();
- X }
- X
- X
- Xstatic void
- Xselect_bank(bank)
- Xchar *bank;
- X { /* select a graphics character set for ANSI terminals */
- X putp(bank);
- X switch (bank[1] & 3) {
- X case 0:
- X putchp('O' & 0x1f); /* control O */
- X break;
- X case 1:
- X putchp('N' & 0x1f); /* control N */
- X putp("\033~");
- X break;
- X case 2:
- X putp("\033n\033}");
- X break;
- X case 3:
- X putp("\033o\033|");
- X break;
- X }
- X }
- X
- X
- Xstatic void
- Xshow_characters(bank, bias)
- Xchar *bank;
- Xint bias;
- X { /* print the ANSI graphics characters */
- X int i;
- X
- X sprintf(temp, "G%d GL ", bank[1] & 3);
- X ptext(temp);
- X select_bank(bank);
- X for (i = ' '; i < 0x80; i++) {
- X if (char_count >= columns ||
- X (i != ' ' && (i & 31) == 0)) put_str("\n ");
- X putchp(i + bias);
- X }
- X select_bank(default_bank);
- X put_str(" DEL <");
- X select_bank(bank);
- X putchp(0x7f + bias);
- X select_bank(default_bank);
- X putchp('>');
- X put_crlf();
- X put_crlf();
- X }
- X
- X
- X/* ANSI graphics test
- X 94 96 character sets
- X G0 ( ,
- X G1 ) -
- X G2 * .
- X G3 + /
- X
- XStandard Definitions
- X A UK
- X B US ASCII
- X
- XDec extended definitions
- X 0 Special graphics
- X
- X */
- X
- Xansi_graphics()
- X { /* test ANSI character sets */
- X int j, ch;
- X char bank[32];
- X
- X put_clear();
- X ptext("Enter the bank ()*+,-./ followed by the character set");
- X ptext(" 0123456789:;<=>? for private use, and");
- X ptextln(" @A...Z[\\]^_`a...z{|}~ for standard sets.");
- X strcpy(bank, "\033)0");
- X for ( ; bank[0]; ) {
- X put_crlf();
- X show_characters(bank, 0);
- X /* G0 will not print in GR */
- X if (bank[1] & 3) show_characters(bank, 0x80);
- X for (j = 1; ch = getchp(char_mask); j++) {
- X if (ch == EOF) break;
- X putchp(ch);
- X if (j == 1 && ch > '/') j++;
- X bank[j] = ch;
- X if (ch < ' ' | ch > '/') break;
- X if (j + 1 >= sizeof(bank)) break;
- X }
- X if (j == 1) break;
- X if (bank[j] < '0' || bank[j] > '~') break;
- X bank[j + 1] = '\0';
- X }
- X }
- END_OF_FILE
- if test 44721 -ne `wc -c <'fun.c'`; then
- echo shar: \"'fun.c'\" unpacked with wrong size!
- fi
- # end of 'fun.c'
- fi
- echo shar: End of archive 1 \(of 7\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 7 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
- exit 0 # Just in case...
- --
- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
- Sterling Software, IMD UUCP: uunet!sparky!kent
- Phone: (402) 291-8300 FAX: (402) 291-4362
- Please send comp.sources.misc-related mail to kent@uunet.uu.net.
-